;(function($){


	$.fn.center=function(){   //垂直居中 调用 : $(".elementName").center();

        return this.each(function(){
        	
        	var $this=$(this),
        		parent=$this.parent(),
        		topPos,
        		topMargin,
        		leftMargin,
        		resizeTimeout;

	        if(parent.is("body:not(.root-height-set)")){
	           
	           $("html,body").css("height","100%").addClass("root-height-set");
	        }


	        if($this.css("position")==="absolute" || $this.css("position")==="fixed"){

	            topPos="50%";
	            topMargin="-"+Math.round($this.outerHeight()/2)+"px";
	            leftMargin="-"+Math.round($this.outerWidth()/2)+"px";
	            $this.css({"left":"50%","margin-left":leftMargin});

	        }else{

	            topPos=Math.floor((parent.height()-$this.outerHeight())/2);
	            topMargin="auto";

	            $this.css({
	            	"display":"block",
	            	"position":"relative",
	            	"margin-left":"auto",
	            	"margin-right":"auto"
	            });
	        }

          	$this.css({"top":topPos,"margin-top":topMargin});

	        $(window).resize(function(){

	        	if(resizeTimeout){

	              clearTimeout(resizeTimeout);

	            }

            resizeTimeout=setTimeout(function(){

		            if($this.css("position")==="absolute"){

		               topMargin="-"+Math.round($this.outerHeight()/2)+"px";
		               leftMargin="-"+Math.round($this.outerWidth()/2)+"px";
		               $this.css({"margin-left":leftMargin,"margin-top":topMargin});

		            }else{

		               topPos=Math.floor((parent.height()-$this.outerHeight())/2);
		               $this.css("top",topPos);

		            }
            },150);

          });

        });
    }

	//字体缩放

    $.fn.fontFlex = function(min, max, mid) {

        var $this = this;

        $(window).resize(function() {

            var size = window.innerWidth / mid;

            if (size < min) size = min;
            if (size > max) size = max;

            $this.css('fonts-size', size + 'px');

        }).trigger('resize');
    };


    //选项卡

	$.extend({

		'tabs' : function(tHead,tConn,tType,childEleName){ //选项卡栏目,内容,触发方式,子元素


			$(tHead).find(childEleName).bind(tType, function() {

				var index = $(this).index();
                $(this).addClass("curt").siblings().removeClass("curt");
                $(tConn).find(childEleName).eq(index).show().siblings().hide();
	
			});

            return this;
		}
		
	})

	
})(jQuery);


/*
	兼容 IE8~IE6 html5 placeholder 属性
*/

var JPlaceHolder = {

    //检测
    _check : function(){
        return 'placeholder' in document.createElement('input');
    },
    //初始化
    init : function(){
        if(!this._check()){
            this.fix();
        }
    },
    //修复
    fix : function(){

        jQuery(':input[placeholder]').each(function(index, element) {

            var self = $(this), txt = self.attr('placeholder');

            self.wrap($('<div></div>').css({position:'relative', zoom:'1', border:'none', background:'none', padding:'none', margin:'none'}));
            var pos = self.position(),
            	h 	= self.outerHeight(true),
            	paddingleft = self.css('padding-left');

            var holder = $('<span class="inputTs"></span>').text(txt).css({

            	position:'absolute',
            	left:pos.left,
            	top:pos.top,
            	height:h,
            	lienHeight:h,
            	paddingLeft:'10px',
            	color:'#f1f1f1'

            }).appendTo(self.parent());
            

            self.focusin(function(e) {
                holder.hide();
            }).focusout(function(e) {
                if(!self.val()){
                    holder.show();
                }
            });
            
            holder.click(function(e) {
                holder.hide();
                self.focus();
            });
        });
    }
};
//执行
jQuery(function(){
    JPlaceHolder.init();    
});


/*
	检测IE版本
*/

function iePrompt(){
	
	function createMent(){
		var promptMent = "<div class=\"prompt\">您的浏览器版本太低，建议升级您的浏览器！</div>";
		$("body").append(promptMent);	
	}


	if (navigator.appName == "Microsoft Internet Explorer") {	

		var browser=navigator.appName
		var b_version=navigator.appVersion
		var version=b_version.split(";");
		var trim_Version=version[1].replace(/[ ]/g,"");

		if(browser=="Microsoft Internet Explorer" && trim_Version=="MSIE7.0"){

    	createMent();
	
		}

		else if(browser=="Microsoft Internet Explorer" && trim_Version=="MSIE8.0")

		{

		    createMent();

		}

	}
	
	
	
	
}

iePrompt();